﻿/*
ColumnChart：
dom：图表渲染容器
xData：x轴
yData:数据
title：标题（默认值为空）
*/
function ColumnChart(colSCharto) {
    this.colSChartDom = colSCharto.dom;
    this.quotatitle = colSCharto.title ? colSCharto.title : " ";
    this.quotatitleD = colSCharto.quotatitleD ? colSCharto.quotatitleD : "";
    this.quotatitleDClass = colSCharto.quotatitleDClass ? colSCharto.quotatitleDClass : "";
    this.xData = colSCharto.xData;
    this.yData = colSCharto.yData;
    this.unit = colSCharto.unit ? colSCharto.unit : "件";
    this.height=colSCharto.height?colSCharto.height:"";
    var self = this;
    var isstringEmpty = self.quotatitleDClass == "" ? false : true;
    return new Highcharts.Chart({
        chart: {
            renderTo: self.colSChartDom,
            type: 'column',
            showAxes: false,
            height:self.height
        },
        title: {
            text: "<div class='" + self.quotatitleDClass + "' alt='" + self.quotatitleD + "' style='display: block;' onmouseover='if(" + isstringEmpty + "){showF(this);}' onmouseout='if(" + isstringEmpty + ")hideF();' >" + self.quotatitle + "</div>",
            useHTML: true,
            style: {
                color: "#3b7197",
                fontWeight: 'bold'
            },
            y: 10
        },
        xAxis: {
            lineWidth: 2,
            lineColor: '#6a6a6a',
            categories: self.xData,
            labels: {
                style: {
                    fontFamily: 'Arial Normal,Arial',
                    fontWeight:400,
                    fontSize: '12px',
                    textAlign:'left'
                },
                text: "<div class='" + self.quotatitleDClass + "' alt='" + self.quotatitleD + "' style='display: block;' onmouseover='if(" + isstringEmpty + "){showF(this);}' onmouseout='if(" + isstringEmpty + ")hideF();' >" + self.quotatitle + "</div>",
                // rotation: -30,
                // formatter: function () {
                //     var val = this.value;
                //
                //     if (this.value&&this.value.length > 5) {
                //         val = $.trim(this.value).substring(0, 4);
                //     }
                //     return val;
                // },
                y: 20

            }
        },
        yAxis: {
            gridLineWidth: 0,
            lineWidth: 2,
            title: {
                text: '单位（' + self.unit + '）',
                align: 'high',
                offset: 0,
                rotation: 0,
                y: -10
            },
            stackLabels: {
                enabled: true,
                style: {
                    fontWeight:"bold",
                    color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                }
            }
        },
        credits: {
            enabled: false
        },
        legend: {
            enabled: true,
            align: 'right',
            x: -30,
            verticalAlign: 'top',
            y: 0,
            floating: true,
            shadow: false,
        },
        colors: ['#ebb867', '#6b9fcf','#8bc267'],
        tooltip: {
            borderColor: '#cacaca',
            borderWidth: 1,
            formatter: function (i) {
                return '<b>' + this.x + '</b><br/>' +
                            this.series.name + ': ' + this.y + '<br/>';
            }
        },
        plotOptions: {
            column: {
                shadow: false,
                width: 25,
                pointPadding: 0,
                borderWidth: 1,
                borderColor: "#acae33",
                stacking: 'normal',
                dataLabels: {
                    enabled: false,
                    y:-10,
                    color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'black'
                }
            }
        },
        series: self.yData
    });
}